//
//  ZZCPlayListTableViewCell.m
//  B段项目
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "ZZCPlayListTableViewCell.h"

@implementation ZZCPlayListTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}


- (void)createSubView{
    
    self.title = [[UILabel alloc]init];
    self.title.font = [UIFont systemFontOfSize:self.frame.size.height / 3];
    self.title.textColor = [UIColor colorWithRed:50/255.0 green:50/255.0 blue:50/255.0 alpha:1.0];
    [self.contentView addSubview:self.title];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).offset(WIDTH / 20);
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.66);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.25);
    }];
    
    self.author = [[UILabel alloc]init];
    self.author.font = [UIFont systemFontOfSize:self.frame.size.height / 4];
    self.author.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1.0];
    [self.contentView addSubview:self.author];
    [self.author mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).offset(WIDTH / 20);
        make.top.equalTo(self.contentView.mas_top).offset(35);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.66);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.25);
    }];
    
    
    self.imgView= [[UIImageView alloc]init];;
    self.imgView.frame = CGRectMake(WIDTH -  WIDTH / 10 , self.frame.size.height / 3,  WIDTH / 18,  WIDTH / 18);
    self.imgView.center = CGPointMake(WIDTH -  WIDTH / 10, self.bounds.size.height / 2 + WIDTH/18/2);
    self.imgView.image = [UIImage imageNamed:@"iconfont-bofangSmall.png"];
    [self.contentView addSubview:self.imgView];
    
    
}

-(void)setPlayListModel:(ZZCPlayListModel *)playListModel{
    
    _playListModel = playListModel;
    
    self.title.text = self.playListModel.title;
    [self.title sizeToFit];
    
    
    self.title.text = self.playListModel.title;
    [self.title sizeToFit];
    self.author.frame = CGRectMake(self.frame.size.width / 20, self.frame.size.height / 10 * 7, self.frame.size.width / 3 * 2, self.frame.size.height / 3);
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"from"] isEqualToString:@"HomePush"]) {
        self.author.text = [NSString stringWithFormat:@"%@",[self.playListModel.userinfo objectForKey:@"uname"]];
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"from"] isEqualToString:@"lun"])
    {
        self.author.text = [NSString stringWithFormat:@"%@",[self.playListModel.authorinfo objectForKey:@"uname"]];
    }else{
        self.author.text = [NSString stringWithFormat:@"%@",[[self.playListModel.playInfo objectForKey:@"userinfo"] objectForKey:@"uname"]];
    }
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
